package com.mf.controller;


import com.mf.groups.GroupsAddInterface;
import com.mf.groups.GroupsUpdateInterface;
import com.mf.result.Result;
import com.mf.utils.UtilConverter;
import com.mf.entity.req.publicReq.ReqPublicIds;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

    
import com.mf.entity.dto.DtoWorkRelation;
import com.mf.entity.req.ReqWorkRelation;
import com.mf.service.ServiceWorkRelation;
import com.mf.entity.req.search.SearchReqWorkRelation;

import java.util.List;

/**
 * 工单之间的关联关系
 * @date 2025-04-21 09:19:55
 */
@RestController
@RequestMapping("workrelation")
@Tag(name = "工单之间的关联关系")
public class ControllerWorkRelation {
    @Resource
    private ServiceWorkRelation serviceworkRelation;

    @Operation(summary = "分页列表查询")
    @PostMapping("/page")
    public Result<Page<DtoWorkRelation>> findPage(@RequestBody SearchReqWorkRelation searchReqWorkRelation) {
        return Result.success(serviceworkRelation.findPageByParams(searchReqWorkRelation));
    }

    @Operation(summary = "列表查询")
    @PostMapping("/list")
    public Result<List<DtoWorkRelation>> list(@RequestBody SearchReqWorkRelation searchReqWorkRelation) {
        return Result.success(serviceworkRelation.findListByParams(searchReqWorkRelation));
    }

    @Operation(summary = "保存")
    @PostMapping("/save")
    public Result<Void> save(@Validated(GroupsAddInterface.class) @RequestBody ReqWorkRelation reqWorkRelation) {
        serviceworkRelation.save(UtilConverter.convert(reqWorkRelation, DtoWorkRelation.class));
        return Result.success();
    }

    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result<Void> update(@Validated(GroupsUpdateInterface.class) @RequestBody ReqWorkRelation reqWorkRelation) {
        serviceworkRelation.updateById(UtilConverter.convert(reqWorkRelation, DtoWorkRelation.class));
        return Result.success();
    }

    @Operation(summary = "删除")
    @PostMapping("/delete")
    public Result<Void> delete(@RequestBody ReqPublicIds<Integer> reqPublicIds) {
        serviceworkRelation.removeByIds(reqPublicIds.getIds());
        return Result.success();
    }

}
